export default function Socket(user) {
    if ('WebSocket' in window) {
        const websock = new WebSocket("ws://" + window.location.host + process.env.VUE_APP_BASE_API + "/websocket/" + user);
        const register = function (obj = {}) {
            //{onopen:this.websocketonopen,onerror:this.websocketonerror,onmessage:this.websocketonmessage,onclose:this.websocketclose}
            for (let key in obj) {
                websock[key] = obj[key]
            }
        }
        return { register }
    } else {
        alert('当前浏览器 Not support websocket')
        return
    }

}